package org.framework.mvc.handler;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * @ClassName: Handler
 * @Auther: Jerry
 * @Date: 2020/7/13 15:35
 * @Desctiption: TODO
 * @Version: 1.0
 */
public class Handler {

    // 当前对象
    private Object target;

    // 正则表达式：用于匹配url
    private Pattern pattern;

    // 调用的方法
    private Method method;

    // 参数下标
    private Map<String, Integer> indexMapping;

    // 权限
    private String[] security;

    public Handler() {
    }

    public Handler(Object target, Pattern pattern, Method method) {
        this.target = target;
        this.pattern = pattern;
        this.method = method;
        this.indexMapping = new HashMap<>();
    }

    public Handler(Object target, Pattern pattern, Method method, String[] security) {
        this.target = target;
        this.pattern = pattern;
        this.method = method;
        this.security = security;
        this.indexMapping = new HashMap<>();
    }

    public Object getTarget() {
        return target;
    }

    public void setTarget(Object target) {
        this.target = target;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Map<String, Integer> getIndexMapping() {
        return indexMapping;
    }

    public void setIndexMapping(Map<String, Integer> indexMapping) {
        this.indexMapping = indexMapping;
    }

    public String[] getSecurity() {
        return security;
    }

    public void setSecurity(String[] security) {
        this.security = security;
    }
}
